#include "lineedit.h"
#include <QFocusEvent>
#include <QTimerEvent>
#include <QTimer>
#include <QWidget>

CLineEdit::CLineEdit(QWidget *parent)
    : QLineEdit(parent)
{
    m_timer.setInterval(300);
    connect(&m_timer, SIGNAL(timeout()), this, SLOT(onTimer()));
}

CLineEdit::~CLineEdit()
{

}

void CLineEdit::onTimer()
{
    setStyleSheet(styleSheet().isEmpty() ? "QLineEdit{background-color:#FFEFD5;border-image:none; border:1px solid gray; border-radius:2px}" : "");
}

void CLineEdit::focusInEvent(QFocusEvent *e)
{
    m_timer.stop();
    setStyleSheet("QLineEdit{background-color:rgb(255,255,240);border-image:none; border:1px solid gray; border-radius:2px}");
    QLineEdit::focusInEvent(e);
}

void CLineEdit::focusOutEvent(QFocusEvent *e)
{
    QLineEdit::focusOutEvent(e);
    //m_timer.stop();
    //setStyleSheet("QLineEdit{background-color:rgb(255,255,240);border-image:none; border:1px solid gray; border-radius:2px}");
}
